home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / regacxcn / frmmain.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-04-27  |  5.7 KB  |  177 lines

  1. VERSION 5.00
  2. Begin VB.Form frmMain 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Registry Example #4"
  5.    ClientHeight    =   3000
  6.    ClientLeft      =   10005
  7.    ClientTop       =   6675
  8.    ClientWidth     =   3720
  9.    Icon            =   "frmMain.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    ScaleHeight     =   3000
  13.    ScaleWidth      =   3720
  14.    StartUpPosition =   1  'CenterOwner
  15.    Begin VB.CommandButton cmdQueryValue 
  16.       Caption         =   "&Query Value"
  17.       Height          =   375
  18.       Left            =   2160
  19.       TabIndex        =   11
  20.       Top             =   2520
  21.       Width           =   1455
  22.    End
  23.    Begin VB.CommandButton cmdSetValue 
  24.       Caption         =   "&Set Value"
  25.       Height          =   375
  26.       Left            =   120
  27.       TabIndex        =   10
  28.       Top             =   2520
  29.       Width           =   1455
  30.    End
  31.    Begin VB.ComboBox cboBaseHkey 
  32.       Height          =   315
  33.       ItemData        =   "frmMain.frx":0442
  34.       Left            =   1560
  35.       List            =   "frmMain.frx":0444
  36.       Style           =   2  'Dropdown List
  37.       TabIndex        =   3
  38.       Top             =   600
  39.       Width           =   2055
  40.    End
  41.    Begin VB.TextBox txtValue 
  42.       Height          =   285
  43.       Left            =   1560
  44.       TabIndex        =   9
  45.       Top             =   2040
  46.       Width           =   2055
  47.    End
  48.    Begin VB.TextBox txtValueName 
  49.       Height          =   285
  50.       Left            =   1560
  51.       TabIndex        =   7
  52.       Top             =   1560
  53.       Width           =   2055
  54.    End
  55.    Begin VB.TextBox txtKeyName 
  56.       Height          =   285
  57.       Left            =   1560
  58.       TabIndex        =   5
  59.       Top             =   1080
  60.       Width           =   2055
  61.    End
  62.    Begin VB.TextBox txtComputerName 
  63.       Height          =   285
  64.       Left            =   1560
  65.       TabIndex        =   1
  66.       Top             =   120
  67.       Width           =   2055
  68.    End
  69.    Begin VB.Label Label6 
  70.       Caption         =   "Value:"
  71.       Height          =   255
  72.       Left            =   120
  73.       TabIndex        =   8
  74.       Top             =   2040
  75.       Width           =   1215
  76.    End
  77.    Begin VB.Label Label4 
  78.       Caption         =   "Value Name:"
  79.       Height          =   255
  80.       Left            =   120
  81.       TabIndex        =   6
  82.       Top             =   1560
  83.       Width           =   1215
  84.    End
  85.    Begin VB.Label Label3 
  86.       Caption         =   "Key Name:"
  87.       Height          =   255
  88.       Left            =   120
  89.       TabIndex        =   4
  90.       Top             =   1080
  91.       Width           =   1215
  92.    End
  93.    Begin VB.Label Label2 
  94.       Caption         =   "Base HKEY:"
  95.       Height          =   255
  96.       Left            =   120
  97.       TabIndex        =   2
  98.       Top             =   600
  99.       Width           =   1215
  100.    End
  101.    Begin VB.Label Label1 
  102.       Caption         =   "Computer Name:"
  103.       Height          =   255
  104.       Left            =   120
  105.       TabIndex        =   0
  106.       Top             =   120
  107.       Width           =   1215
  108.    End
  109. Attribute VB_Name = "frmMain"
  110. Attribute VB_GlobalNameSpace = False
  111. Attribute VB_Creatable = False
  112. Attribute VB_PredeclaredId = True
  113. Attribute VB_Exposed = False
  114. '****************************************************************************************************
  115. '   Copyright (c) Key Technology Pty Ltd 1998-1999, All Rights Reserved.
  116. '   Web site: http://www.keytech.com.au  Email: info@keytech.com.au
  117. '****************************************************************************************************
  118. Option Explicit
  119. Private Reg As New RegistryAccessor
  120. Private Sub cmdQueryValue_Click()
  121.     On Error Resume Next
  122.     ' Get the value
  123.     Dim Value As Variant
  124.     With Reg
  125.         .ComputerName = txtComputerName.Text
  126.         .HKEY = cboBaseHkey.ItemData(cboBaseHkey.ListIndex)
  127.         .SubKey = txtKeyName.Text
  128.         .ValueName = txtValueName.Text
  129.         
  130.         Value = .Value
  131.     End With
  132.     If Err.Number <> 0 Then
  133.         MsgBox "Failed to query value - " & _
  134.                Err.Description & " (" & Hex(Err.Number) & ")"
  135.         Err.Clear
  136.         Exit Sub
  137.     End If
  138.     ' Display the value
  139.     txtValue.Text = Value
  140. End Sub
  141. Private Sub cmdSetValue_Click()
  142.     On Error Resume Next
  143.     ' Set the value
  144.     With Reg
  145.         .ComputerName = txtComputerName.Text
  146.         .HKEY = cboBaseHkey.ItemData(cboBaseHkey.ListIndex)
  147.         .SubKey = txtKeyName.Text
  148.         .ValueName = txtValueName.Text
  149.         
  150.         .Value = txtValue.Text
  151.     End With
  152.     If Err.Number <> 0 Then
  153.         MsgBox "Failed to set value - " & _
  154.                Err.Description & " (" & Hex(Err.Number) & ")"
  155.         Err.Clear
  156.         Exit Sub
  157.     End If
  158. End Sub
  159. Private Sub Form_Load()
  160.     ' Initialize the base HKEY combo
  161.     cboBaseHkey.AddItem "LOCAL_MACHINE"
  162.     cboBaseHkey.ItemData(cboBaseHkey.NewIndex) = REG_HKEY_LOCAL_MACHINE
  163.     cboBaseHkey.AddItem "CLASSES_ROOT"
  164.     cboBaseHkey.ItemData(cboBaseHkey.NewIndex) = REG_HKEY_CLASSES_ROOT
  165.     cboBaseHkey.AddItem "CURRENT_CONFIG"
  166.     cboBaseHkey.ItemData(cboBaseHkey.NewIndex) = REG_HKEY_CURRENT_CONFIG
  167.     cboBaseHkey.AddItem "CURRENT_USER"
  168.     cboBaseHkey.ItemData(cboBaseHkey.NewIndex) = REG_HKEY_CURRENT_USER
  169.     cboBaseHkey.AddItem "DYN_DATA"
  170.     cboBaseHkey.ItemData(cboBaseHkey.NewIndex) = REG_HKEY_DYN_DATA
  171.     cboBaseHkey.AddItem "PERF_DATA"
  172.     cboBaseHkey.ItemData(cboBaseHkey.NewIndex) = REG_HKEY_PERFORMANCE_DATA
  173.     cboBaseHkey.AddItem "USERS"
  174.     cboBaseHkey.ItemData(cboBaseHkey.NewIndex) = REG_HKEY_USERS
  175.     cboBaseHkey.ListIndex = 0
  176. End Sub
  177.